import cn.edu.hbsi.dao.OrdersDao;
import cn.edu.hbsi.domain.Orders;
import cn.edu.hbsi.utils.GetSqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Test;

import java.util.Iterator;
import java.util.List;

public class testOrders
{
    private SqlSession sqlSession = GetSqlSessionUtil.getSqlSession();
    private OrdersDao ordersDao = sqlSession.getMapper(OrdersDao.class);

    @Test
    public void testSelectOrdersByUId(){
        Integer uId = 1;

        List<Orders> orders = ordersDao.selectOrdersByUId(uId);
        Iterator var = orders.iterator();
        while (var.hasNext()){
            Orders orders1 = (Orders) var.next();
            System.out.println(orders1);
        }
    }

    @Test
    public void testSelectOrdersWithProduct(){
        Integer oId = 1;

        List<Orders> list = ordersDao.selectOrdersWithProduct(oId);

        Iterator var = list.iterator();
        while (var.hasNext()){
            Orders orders = (Orders) var.next();
            System.out.println(orders);
        }
    }

    @After
    public void destory(){
        sqlSession.commit();
        sqlSession.close();
    }
}
